import random

from wcs.libs.items import items
from wcs.libs.players import players

itemName = 'Flaming Glove Of Warmth'
item = items.addItem(itemName)
item.setGroup("special")
item.setCost(5500)
item.setDescription("15% chance to burn a victim for 2 seconds")
item.aliveToUse = True
item.setMaxCount(1)

def player_hurt(event_var):
    """
    Executed when a player is hurt. If the attacker has this item purcahsed, do
    a dice throw and if the result is true (15% chance) burn the victim for 2
    seconds.
    """
    attacker = int(event_var["attacker"]) if event_var["attacker"] else 0
    userid = int(event_var["userid"])
    if attacker and event_var['es_userteam'] != event_var['es_attackerteam']:
        if players[attacker].getItem(itemName).count:
            if random.randint(1, 100) <= 15:
                players[userid].burn(2)
